class ZcmController < ApplicationController

  layout "main"

  def index
    @menu_index=1
    @pagetitle="全部注册码列表"
    #@zcms = Zcm.find(:all)
    @zcms=Zcm.paginate(:page => params[:page]||1,:order=>"created_at desc")

  end

  def show
    @menu_index=1
    @zcm = Zcm.find(params[:id])
    @zcm.clickday+=1
    @zcm.clickweek+=1
    @zcm.clickmonth+=1    
    @zcm.clicktotal+=1    
    @zcm.update_attributes(@zcm.attributes)
    @pagetitle=@zcm.title
    @comment=Comment.new(:parent_id=>@zcm.id,:comment_type=>1)
    @comments=Comment.paginate_by_sql(["select * from comments where parent_id=? and comment_type=? order by created_at desc",@zcm.id,1],:page => params[:page]||1)
  end
  
  def search
    @menu_index=1
    @keyword=params[:keyword] || ''
    @zcms= Zcm.paginate(:conditions=>["title like ?",'%'+@keyword+'%'],:page => params[:page]||1,:order=>"created_at desc") 
  end
  
  def cate
    @menu_index=1
    @zcms= Zcm.paginate_by_letter(params[:letter],:page => params[:page]||1,:order=>"title")
    
  end
  
end
